﻿using System;
using UnityEngine;

namespace Spline
{
	// Token: 0x020003FF RID: 1023
	internal class TNS : SNS
	{
		// Token: 0x06001982 RID: 6530 RVA: 0x000A4D48 File Offset: 0x000A2F48
		public void AddNode(Vector3 pos, float timePeriod)
		{
			if (this.nodeCount == 0)
			{
				this.maxDistance = 0f;
			}
			else
			{
				this.node[this.nodeCount - 1].distance = timePeriod;
				this.maxDistance += this.node[this.nodeCount - 1].distance;
			}
			this.node[this.nodeCount++].position = pos;
		}

		// Token: 0x06001983 RID: 6531 RVA: 0x000A4DD0 File Offset: 0x000A2FD0
		public override void BuildSpline()
		{
			base.Build();
			this.Smooth();
			this.Smooth();
			this.Smooth();
		}

		// Token: 0x06001984 RID: 6532 RVA: 0x000A4DEC File Offset: 0x000A2FEC
		protected override void Smooth()
		{
			base.Smoothing();
			this.Constrain();
		}

		// Token: 0x06001985 RID: 6533 RVA: 0x000A4DFC File Offset: 0x000A2FFC
		public void Constrain()
		{
			for (int i = 1; i < this.nodeCount - 1; i++)
			{
				float num = Vector3.Distance(this.node[i].position, this.node[i - 1].position) / this.node[i - 1].distance;
				float num2 = Vector3.Distance(this.node[i + 1].position, this.node[i].position) / this.node[i].distance;
				RNS.splineData[] node = this.node;
				int num3 = i;
				node[num3].velocity = node[num3].velocity * (4f * num * num2 / ((num + num2) * (num + num2)));
			}
		}

		// Token: 0x06001986 RID: 6534 RVA: 0x000A4ECC File Offset: 0x000A30CC
		protected void ConstrainLast()
		{
			int num = this.nodeCount - 2;
			float num2 = Vector3.Distance(this.node[num].position, this.node[num - 1].position) / this.node[num - 1].distance;
			float num3 = Vector3.Distance(this.node[num + 1].position, this.node[num].position) / this.node[num].distance;
			RNS.splineData[] node = this.node;
			int num4 = num;
			node[num4].velocity = node[num4].velocity * (4f * num2 * num3 / ((num2 + num3) * (num2 + num3)));
		}

		// Token: 0x06001987 RID: 6535 RVA: 0x000A4F8C File Offset: 0x000A318C
		protected override void SmoothingLast()
		{
			this.node[this.nodeCount - 1].velocity = base.GetEndVelocity(this.nodeCount - 1);
			this.ConstrainLast();
		}

		// Token: 0x06001988 RID: 6536 RVA: 0x000A4FBC File Offset: 0x000A31BC
		public override float RenewMove(Vector3 pos, float time)
		{
			int num;
			int num2;
			float rate;
			base.TimeState(time, out num, out num2, out rate);
			base.RemoveHeadNode();
			base.AddNode(pos);
			base.BuildLast();
			this.SmoothingLast();
			this.SmoothingLast();
			this.SmoothingLast();
			return base.GetTime(num - 1, rate);
		}
	}
}
